import { ElMessage } from "element-plus"

export const resultHandle = (res, resultHandle, useMessage = false) => {
    if (res.success === true) {
        resultHandle && resultHandle()
        if (!resultHandle || useMessage) {
            ElMessage({
                type: 'success',
                message: res.message
            })
        }
    } else {
        ElMessage({
            type: 'error',
            message: res.message
        })
    }
}

export const generateMap = (list, keyName, valueName) => {
    const obj = {}
    list.forEach(item => { obj[item[keyName]] = item[valueName] })
    return obj
}


